<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>添加/编辑楼层tab - Powered By ${systemConfig.systemName}</title>
<meta name="Author" content="webmall Team" />
<meta name="Copyright" content="webmall" />
<link rel="icon" href="favicon.ico" type="image/x-icon" />
<#include "/WEB-INF/template/common/include.ftl">
<link href="${base}/template/admin/css/input.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">

</script>
<style type="text/css">
<!--

.deleteImage, #addImage, #removeImage {
	cursor: pointer;
}

-->
</style>
<#if !id??>
	<#assign isAdd = true />
<#else>
	<#assign isEdit = true />
</#if>
</head>
<body class="input">
	<div class="body">
		<div class="inputBar">
			<h1><span class="icon">&nbsp;</span><#if isAdd??>添加楼层tab<#else>编辑楼层tab</#if></h1>
		</div>
		<form id="inputForm" class="validate" action="<#if isAdd??>indexfloortab!save.action<#else>indexfloortab!update.action</#if>" method="post">
			<input type="hidden" name="id" value="${id}" />
			<input type="hidden" name="indexfloorId" value="${indexfloorId}" />
			<table class="inputTable">
				<tr>
					<th>
						所属首页楼层:
					</th>
					<td>
						<select name="indexfloortab.indexfloor.id" id="indexfloorId" class="{required: true}">
							<option value="">请选择...</option>
							<#list allIndexfloor as list>
								<option value="${list.id}"<#if (list.id == indexfloorId || list.id == indexfloortab.indexfloor.id)!> selected </#if>>${list.name}</option>
							</#list>
						</select>
						<lable class="requireField">*</lable>
					</td>
				</tr>
				<tr>
					<th>
						楼层tab名称:
					</th>
					<td>
						<input type="text" name="indexfloortab.name" id="indexfloortabName" class="formText {required: true}" value="${(indexfloortab.name)!}" />
						<lable class="requireField">*</lable>
					</td>
				</tr>
				
				
				<tr>
					<th>
						排序:
					</th>
					<td>
						<input type="text" name="indexfloortab.orderList" class="formText {digits: true, required:true}" value="${(indexfloortab.orderList)!50}" title="只允许输入零或正整数" />
						<label class="requireField">*</label>
					</td>
				</tr>
				
				<tr>
					<th>
						是否启用:
					</th>
					<td>
						<label><input type="radio" name="indexfloortab.isEnabled" value="true"<#if (isAdd || indexfloortab.isEnabled == true)!> checked</#if> />是</label>
						<label><input type="radio" name="indexfloortab.isEnabled" value="false"<#if (indexfloortab.isEnabled == false)!> checked</#if> />否</label>
					</td>
				</tr>
				<tr>
					<th>
						包含商品:
					</th>
					<td>
						<div class="" style="padding-left:10px;margin-bottom:10px;">
							<form action="javascript:searchProduct();" name="searchForm">
							    <!-- 分类 -->
							  搜索：分类：<select name="sproductCategory" id="sproductCategory">
									<option value="">请选择...</option>
									<#list productCategoryTreeList as list>
										<option value="${list.id}"<#if (list.id == product.productCategory.id)!> selected</#if>>
											<#if list.level != 0>
												<#list 1..list.level as i>------</#list>
											</#if>
											${list.name}
										</option>
									</#list>
								</select>
							    <!-- 品牌 -->
							    品牌：
							    <select name="sbrand" id="sbrand">
									<option value="">请选择...</option>
									<#list allBrand as list>
										<option value="${list.id}"<#if (list.id == product.brand.id)!> selected </#if>>
											${list.name}
										</option>
									</#list>
								</select>
							    <!-- 关键字 -->
							    名称：
							    <input type="text" name="skeyword" size="20" id="skeyword">
							    <input type="button" value=" 搜索 " class="button" onclick="searchProduct();">
							</form>
							<br/>
							产品名称：
							<select id="product"  class="formText">
								<#if (groupbuy != null && groupbuy.product != null)>
									<option value="${groupbuy.product.id}">${groupbuy.product.name}</option>
								<#else>
									<option value="">请选择...</option>
								</#if>
								
							</select>
							<label class="requireField">*</label>
							<input type="button" value="添加商品" id="product_add"/>
						</div>
					</td>
				</tr>
				<tr>
					<th>
						产品列表:
					</th>
					<td>
						<div style="width: 60%; float: left;" id="products">
							<#if (indexfloortab != null && indexfloortab.productList != null && indexfloortab.productList?size >0) >
							<#list indexfloortab.productList as list>
								<label><input type="checkbox" name="productIds" value="${list.id}"  checked="checked" />${(list.name)!}</label>
							</#list>
							</#if>
						</div>
					</td>
				</tr>
				
				
				
			</table>
			<div class="buttonArea">
				<input type="submit" class="formButton" value="确  定" hidefocus="true" />&nbsp;&nbsp;&nbsp;&nbsp;
				<input type="button" class="formButton" onclick="window.history.back(); return false;" value="返  回" hidefocus="true" />
			</div>
		</form>
	</div>
	<script type="text/javascript">
		$(function(){
		
			$("#product_add").click(function(){
				if($("#product").val() == ""){
					alert("请先搜索要添加的商品！");
					return ;
				}
				var exsit_product = false;
				$("input[name='productIds']").each(function(){
					if($(this).val() == $("#product").val()){
						alert("商品已存在！");
						exsit_product = true;
					}
				});
				
				if(!exsit_product){
					var html_pro = '<label><input type="checkbox" name="productIds" value="'+$("#product").val()+'"  checked="checked" />'+$('#product option:selected').text()+'</label>';
					$("#products").append(html_pro);
				}
				
				/*
				$("input[name='productIds']").click(function(){
					if(!$(this).attr("checked")){
						$(this).parent().remove();
					}
				});
				*/
			});
		})
		
	</script>
</body>
</html>